<template>
  <div class="">

    <el-row :gutter="20">
      <el-col :span="16" :offset="3">
        <div class="grid-content bg-purple container">
          <div style="margin-top: 20px">

            <el-card class="box-card">
              <div slot="header" class="clearfix">
                <span>基本信息：</span>

              </div>
              <el-form ref="form" :model="myinfo" label-width="80px">
                <el-form-item label="账户：">
                  <el-input disabled v-model="myinfo.name"></el-input>
                </el-form-item>
                <el-form-item label="姓名：">
                  <el-input  v-model="myinfo.realname"></el-input>
                </el-form-item>
                <el-form-item label="密码：">
                  <el-input type="password"  v-model="myinfo.password"></el-input>
                </el-form-item>
                <el-form-item label="状态：">
                  <el-tag v-if="myinfo.status==0" type="success">可用</el-tag>
                  <el-tag v-else-if="myinfo.status==1" type="danger">禁用</el-tag>

                </el-form-item>
                <el-form-item label="操作：">
                  <el-button @click="save()">保存</el-button>
                </el-form-item>
              </el-form>
            </el-card>
          </div>
          <div  style="margin-top: 20px">

            <el-card class="box-card">
              <div slot="header" class="clearfix">
                <span>我的考试：</span>
              </div>
              <div v-for="answeritem in answerresultlist" :key="answeritem.id" class="text item">
                <div class="answeritem">
                  <el-row>

                      <img class="paperimg" :src="'http://localhost:8080/downloadFile/'+ answeritem.paper.img"  />

                      <div class="title">试卷：{{answeritem.paper.name}}</div>
                      <div class="info">答题时间：{{answeritem.createtime}}</div>
                      <div class="info2">分数：<span style="color: green;font-size: x-large">{{answeritem.score}} </span> </div>

                  </el-row>
                </div>
              </div>
            </el-card>
          </div>
        </div>
      </el-col>
    </el-row>



  </div>
</template>

<script>
  import { login, changepass,getMyInfo,answerResult } from "@/api/student";

  export default {
    name: "login",
    data() {
      return {
        myinfo: {
        },
        answerresultlist:[],
      };
    },
    created() {
      this.getMyInfo();

    },
    methods: {
      save() {
        changepass(this.myinfo).then(res=>{
          console.log(res)
          if(res.code == 1) {
            this.$message.success("修改成功！")
          }
        })
      },
      getMyInfo(e){
        getMyInfo({}).then(res=>{
          this.myinfo = res.info
          console.log(res)
        })
        answerResult({}).then(res=>{
          this.answerresultlist = res.info
        })
        console.log(e)
      },
    },
  };
</script>

<style rel="stylesheet/scss" lang="scss">
  $bg: #ffffff;
  $dark_gray: #ffffff;
  $light_gray: rgb(250, 250, 250);

.container{
  margin-top: 20px;
}
  .answeritem {
    float: left;
    width: 300px;
    border-radius: 5px;

    background-color: #d2d5db;
    margin: 10px;
    .paperimg{
      border-radius: 5px;
      width: 300px;
      height: 200px;
    }
    .title{
      color: #293444;
      font-size: x-large;
      margin: 5px;
    }
    .info{
      color: #293444;
      font-size: medium;
      margin: 5px;
    }

  }
</style>
